package com.fangcun.service.api.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fangcun.bean.api.category.response.CategoryWithChildrenResponse;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.exception.ProValiDataException;
import com.fangcun.mapper.GoodsCategoryMapper;
import com.fangcun.service.api.GoodsCategoryServicer;

@Service
public class GoodsCategoryServicerImpl implements GoodsCategoryServicer{
	
	@Autowired
	private GoodsCategoryMapper goodsCategoryMapper;
	
	@Override
	public List<CategoryWithChildrenResponse> list(Long teahouseId) throws ProException {
		List<CategoryWithChildrenResponse>  list=goodsCategoryMapper.listWithChildren(teahouseId);
		if(list == null || list.size() == 0) {
			throw new ProValiDataException(ErrCode.NO_DATA.getReturnCode(), ErrCode.NO_DATA.getReturnMsg());
		}
//		if (request.getLevel() == null) {
//			request.setLevel(0);
//		}
//		List<GoodsCategory> list = goodsCategoryMapper.list(request);
//		if (list == null || list.size() == 0) {
//			throw new ProValiDataException(ErrCode.NO_DATA.getReturnCode(), ErrCode.NO_DATA.getReturnMsg());
//		}
		return list;
	}
	
}
